package com.alibaba.csp.sentinel.dashboard.rule.apollo;

import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity;
import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName FlowRuleApolloProvider
 * @Description TODO
 * @Author zhouchao
 * @Date 2020/2/17 20:11
 * @Version 1.0
 */
@Component("flowRuleApolloProvider")
public class FlowRuleApolloProvider extends AbstractApolloCommonService implements
        DynamicRuleProvider<List<FlowRuleEntity>> {
    @Autowired
    private SentinelApiClient sentinelApiClient;

    @Override
    public List<FlowRuleEntity> getRules(String appName) throws Exception {
        List<FlowRuleEntity> rules = apolloCommonService.getRules(appName, flowDataIdSuffix, FlowRuleEntity.class);
        return rules;
    }
}
